namespace QMVnSoft.Opening
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormCDSEditor : FormOpenningEditor
    {
        private IContainer components;
        private LabelControl lblDM_Luong;
        private LabelControl lblDM_Luong0;
        private LabelControl lblGia;
        private LabelControl lblGia_Nt;
        private LabelControl lblMa_Dt;
        private LabelControl lblMa_Sp;
        private LabelControl lblMa_Vt;
        private LabelControl lblSo_Luong;
        private LabelControl lblTien;
        private LabelControl lblTien_Nt;
        private LabelControl lblTk;
        private LabelControl lblTk_Du;
        private TextOption txtDM_Luong;
        private TextNumeric txtGia;
        private TextNumeric txtGia_Nt;
        private TextSearch txtMa_Dt;
        private TextSearch txtMa_Sp;
        private TextSearch txtMa_Vt;
        private TextNumeric txtSo_Luong;
        private TextControl txtTen_Dt;
        private TextControl txtTen_Sp;
        private TextControl txtTen_Tk;
        private TextControl txtTen_Tk_Du;
        private TextControl txtTen_Vt;
        private TextNumeric txtTien;
        private TextNumeric txtTien_Nt;
        private TextSearch txtTk;
        private TextSearch txtTk_Du;

        public FormCDSEditor()
        {
            this.InitializeComponent();
        }

        private void Calculate(int pi_Position)
        {
            if (pi_Position == 1)
            {
                this.txtTien.Value = decimal.Round(this.txtSo_Luong.NumericValue * this.txtGia.NumericValue, AppInstance.LCAmountDecimals);
                this.txtTien_Nt.Value = decimal.Round(this.txtSo_Luong.NumericValue * this.txtGia_Nt.NumericValue, AppInstance.FCAmountDecimals);
            }
            else if (pi_Position == 2)
            {
                this.txtTien.Value = decimal.Round(this.txtSo_Luong.NumericValue * this.txtGia.NumericValue, AppInstance.LCAmountDecimals);
            }
            else if ((pi_Position == 3) && (this.txtSo_Luong.NumericValue != 0M))
            {
                this.txtGia.Value = decimal.Round(this.txtTien.NumericValue / this.txtSo_Luong.NumericValue, AppInstance.LCPriceDecimals);
            }
            else if (pi_Position == 4)
            {
                this.txtTien_Nt.Value = decimal.Round(this.txtSo_Luong.NumericValue * this.txtGia_Nt.NumericValue, AppInstance.FCAmountDecimals);
            }
            else if ((pi_Position == 5) && (this.txtSo_Luong.NumericValue != 0M))
            {
                this.txtGia_Nt.Value = decimal.Round(this.txtTien_Nt.NumericValue / this.txtSo_Luong.NumericValue, AppInstance.FCPriceDecimals);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCDSEditor));
            this.txtTen_Sp = new QMVnSoft.Controls.TextControl();
            this.txtMa_Sp = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Sp = new QMVnSoft.Controls.LabelControl();
            this.lblTien = new QMVnSoft.Controls.LabelControl();
            this.txtTien = new QMVnSoft.Controls.TextNumeric();
            this.txtSo_Luong = new QMVnSoft.Controls.TextNumeric();
            this.lblSo_Luong = new QMVnSoft.Controls.LabelControl();
            this.lblTk = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Tk = new QMVnSoft.Controls.TextControl();
            this.txtTk = new QMVnSoft.Controls.TextSearch();
            this.lblTk_Du = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Tk_Du = new QMVnSoft.Controls.TextControl();
            this.txtTk_Du = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Dt = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Dt = new QMVnSoft.Controls.TextControl();
            this.txtMa_Dt = new QMVnSoft.Controls.TextSearch();
            this.lblDM_Luong0 = new QMVnSoft.Controls.LabelControl();
            this.txtDM_Luong = new QMVnSoft.Controls.TextOption();
            this.lblDM_Luong = new QMVnSoft.Controls.LabelControl();
            this.lblMa_Vt = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Vt = new QMVnSoft.Controls.TextControl();
            this.txtMa_Vt = new QMVnSoft.Controls.TextSearch();
            this.txtGia = new QMVnSoft.Controls.TextNumeric();
            this.lblGia = new QMVnSoft.Controls.LabelControl();
            this.txtTien_Nt = new QMVnSoft.Controls.TextNumeric();
            this.txtGia_Nt = new QMVnSoft.Controls.TextNumeric();
            this.lblTien_Nt = new QMVnSoft.Controls.LabelControl();
            this.lblGia_Nt = new QMVnSoft.Controls.LabelControl();
            this.SuspendLayout();
            // 
            // txtTen_Sp
            // 
            this.txtTen_Sp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Sp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Sp.CheckTextSearched = false;
            this.txtTen_Sp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Enabled = false;
            this.txtTen_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Sp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Location = new System.Drawing.Point(210, 31);
            this.txtTen_Sp.Name = "txtTen_Sp";
            this.txtTen_Sp.OldValue = null;
            this.txtTen_Sp.Size = new System.Drawing.Size(296, 13);
            this.txtTen_Sp.TabIndex = 80;
            this.txtTen_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Sp.Value = ((object)(resources.GetObject("txtTen_Sp.Value")));
            // 
            // txtMa_Sp
            // 
            this.txtMa_Sp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Sp.CheckTextSearched = false;
            this.txtMa_Sp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Sp.FieldDisplay = "Ten_Sp";
            this.txtMa_Sp.FirstFilter = "SP_CT = \'C\'";
            this.txtMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Sp.Location = new System.Drawing.Point(93, 28);
            this.txtMa_Sp.MaxLength = 32;
            this.txtMa_Sp.Name = "txtMa_Sp";
            this.txtMa_Sp.OldValue = null;
            this.txtMa_Sp.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Sp.TabIndex = 0;
            this.txtMa_Sp.TableName = "DMSP";
            this.txtMa_Sp.TextDisplay = this.txtTen_Sp;
            this.txtMa_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Sp.Value = ((object)(resources.GetObject("txtMa_Sp.Value")));
            // 
            // lblMa_Sp
            // 
            this.lblMa_Sp.AutoSize = true;
            this.lblMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Sp.Location = new System.Drawing.Point(12, 31);
            this.lblMa_Sp.Name = "lblMa_Sp";
            this.lblMa_Sp.Size = new System.Drawing.Size(56, 14);
            this.lblMa_Sp.TabIndex = 78;
            this.lblMa_Sp.Text = "Công trình";
            // 
            // lblTien
            // 
            this.lblTien.AutoSize = true;
            this.lblTien.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTien.Location = new System.Drawing.Point(12, 199);
            this.lblTien.Name = "lblTien";
            this.lblTien.Size = new System.Drawing.Size(57, 14);
            this.lblTien.TabIndex = 86;
            this.lblTien.Text = "Thành tiền";
            // 
            // txtTien
            // 
            this.txtTien.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTien.Location = new System.Drawing.Point(93, 196);
            this.txtTien.Name = "txtTien";
            this.txtTien.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTien.OldValue = null;
            this.txtTien.Size = new System.Drawing.Size(162, 20);
            this.txtTien.TabIndex = 8;
            this.txtTien.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTien.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.txtTien.Value = ((object)(resources.GetObject("txtTien.Value")));
            this.txtTien.Validated += new System.EventHandler(this.txtTien_Validated);
            // 
            // txtSo_Luong
            // 
            this.txtSo_Luong.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSo_Luong.Location = new System.Drawing.Point(93, 154);
            this.txtSo_Luong.Name = "txtSo_Luong";
            this.txtSo_Luong.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtSo_Luong.OldValue = null;
            this.txtSo_Luong.Size = new System.Drawing.Size(162, 20);
            this.txtSo_Luong.TabIndex = 6;
            this.txtSo_Luong.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtSo_Luong.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.txtSo_Luong.Value = ((object)(resources.GetObject("txtSo_Luong.Value")));
            this.txtSo_Luong.Validated += new System.EventHandler(this.txtSo_Luong_Validated);
            // 
            // lblSo_Luong
            // 
            this.lblSo_Luong.AutoSize = true;
            this.lblSo_Luong.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblSo_Luong.Location = new System.Drawing.Point(12, 157);
            this.lblSo_Luong.Name = "lblSo_Luong";
            this.lblSo_Luong.Size = new System.Drawing.Size(51, 14);
            this.lblSo_Luong.TabIndex = 86;
            this.lblSo_Luong.Text = "Số lượng";
            // 
            // lblTk
            // 
            this.lblTk.AutoSize = true;
            this.lblTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTk.Location = new System.Drawing.Point(12, 52);
            this.lblTk.Name = "lblTk";
            this.lblTk.Size = new System.Drawing.Size(53, 14);
            this.lblTk.TabIndex = 78;
            this.lblTk.Text = "Tài khoản";
            // 
            // txtTen_Tk
            // 
            this.txtTen_Tk.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Tk.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Tk.CheckTextSearched = false;
            this.txtTen_Tk.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Enabled = false;
            this.txtTen_Tk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Tk.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Location = new System.Drawing.Point(210, 52);
            this.txtTen_Tk.Name = "txtTen_Tk";
            this.txtTen_Tk.OldValue = null;
            this.txtTen_Tk.Size = new System.Drawing.Size(296, 13);
            this.txtTen_Tk.TabIndex = 80;
            this.txtTen_Tk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Tk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Tk.Value = ((object)(resources.GetObject("txtTen_Tk.Value")));
            // 
            // txtTk
            // 
            this.txtTk.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtTk.CheckTextSearched = false;
            this.txtTk.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTk.FieldDisplay = "Ten_Tk";
            this.txtTk.FirstFilter = "Loai_Tk = \'C\'";
            this.txtTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTk.Location = new System.Drawing.Point(93, 49);
            this.txtTk.MaxLength = 32;
            this.txtTk.Name = "txtTk";
            this.txtTk.OldValue = null;
            this.txtTk.Size = new System.Drawing.Size(111, 20);
            this.txtTk.TabIndex = 1;
            this.txtTk.TableName = "DMTK";
            this.txtTk.TextDisplay = this.txtTen_Tk;
            this.txtTk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtTk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTk.Value = ((object)(resources.GetObject("txtTk.Value")));
            // 
            // lblTk_Du
            // 
            this.lblTk_Du.AutoSize = true;
            this.lblTk_Du.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTk_Du.Location = new System.Drawing.Point(12, 73);
            this.lblTk_Du.Name = "lblTk_Du";
            this.lblTk_Du.Size = new System.Drawing.Size(57, 14);
            this.lblTk_Du.TabIndex = 78;
            this.lblTk_Du.Text = "Tk đối ứng";
            // 
            // txtTen_Tk_Du
            // 
            this.txtTen_Tk_Du.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Tk_Du.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Tk_Du.CheckTextSearched = false;
            this.txtTen_Tk_Du.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk_Du.Enabled = false;
            this.txtTen_Tk_Du.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Tk_Du.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk_Du.Location = new System.Drawing.Point(210, 73);
            this.txtTen_Tk_Du.Name = "txtTen_Tk_Du";
            this.txtTen_Tk_Du.OldValue = null;
            this.txtTen_Tk_Du.Size = new System.Drawing.Size(296, 13);
            this.txtTen_Tk_Du.TabIndex = 80;
            this.txtTen_Tk_Du.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Tk_Du.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Tk_Du.Value = ((object)(resources.GetObject("txtTen_Tk_Du.Value")));
            // 
            // txtTk_Du
            // 
            this.txtTk_Du.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtTk_Du.CheckTextSearched = false;
            this.txtTk_Du.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTk_Du.FieldDisplay = "Ten_Tk";
            this.txtTk_Du.FirstFilter = "Loai_Tk = \'C\'";
            this.txtTk_Du.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTk_Du.Location = new System.Drawing.Point(93, 70);
            this.txtTk_Du.MaxLength = 32;
            this.txtTk_Du.Name = "txtTk_Du";
            this.txtTk_Du.OldValue = null;
            this.txtTk_Du.Size = new System.Drawing.Size(111, 20);
            this.txtTk_Du.TabIndex = 2;
            this.txtTk_Du.TableName = "DMTK";
            this.txtTk_Du.TextDisplay = this.txtTen_Tk_Du;
            this.txtTk_Du.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtTk_Du.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTk_Du.Value = ((object)(resources.GetObject("txtTk_Du.Value")));
            // 
            // lblMa_Dt
            // 
            this.lblMa_Dt.AutoSize = true;
            this.lblMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Dt.Location = new System.Drawing.Point(12, 94);
            this.lblMa_Dt.Name = "lblMa_Dt";
            this.lblMa_Dt.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Dt.TabIndex = 78;
            this.lblMa_Dt.Text = "Đối tượng";
            // 
            // txtTen_Dt
            // 
            this.txtTen_Dt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Dt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Dt.CheckTextSearched = false;
            this.txtTen_Dt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Enabled = false;
            this.txtTen_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Dt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Location = new System.Drawing.Point(210, 94);
            this.txtTen_Dt.Name = "txtTen_Dt";
            this.txtTen_Dt.OldValue = null;
            this.txtTen_Dt.Size = new System.Drawing.Size(296, 13);
            this.txtTen_Dt.TabIndex = 80;
            this.txtTen_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Dt.Value = ((object)(resources.GetObject("txtTen_Dt.Value")));
            // 
            // txtMa_Dt
            // 
            this.txtMa_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Dt.CheckTextSearched = false;
            this.txtMa_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Dt.EmptyIsValid = true;
            this.txtMa_Dt.FieldDisplay = "Ten_Dt";
            this.txtMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Dt.FoundIsValid = true;
            this.txtMa_Dt.Location = new System.Drawing.Point(93, 91);
            this.txtMa_Dt.MaxLength = 32;
            this.txtMa_Dt.Name = "txtMa_Dt";
            this.txtMa_Dt.OldValue = null;
            this.txtMa_Dt.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Dt.TabIndex = 3;
            this.txtMa_Dt.TableName = "DMDT";
            this.txtMa_Dt.TextDisplay = this.txtTen_Dt;
            this.txtMa_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Dt.Value = ((object)(resources.GetObject("txtMa_Dt.Value")));
            // 
            // lblDM_Luong0
            // 
            this.lblDM_Luong0.AutoSize = true;
            this.lblDM_Luong0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDM_Luong0.ForeColor = System.Drawing.Color.Blue;
            this.lblDM_Luong0.Location = new System.Drawing.Point(122, 115);
            this.lblDM_Luong0.Name = "lblDM_Luong0";
            this.lblDM_Luong0.Size = new System.Drawing.Size(198, 14);
            this.lblDM_Luong0.TabIndex = 92;
            this.lblDM_Luong0.Text = "L-Số dư theo lượng, T-Số dư theo giá trị";
            // 
            // txtDM_Luong
            // 
            this.txtDM_Luong.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtDM_Luong.CheckTextSearched = false;
            this.txtDM_Luong.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtDM_Luong.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDM_Luong.InputMask = "T,L";
            this.txtDM_Luong.Location = new System.Drawing.Point(93, 112);
            this.txtDM_Luong.Name = "txtDM_Luong";
            this.txtDM_Luong.OldValue = null;
            this.txtDM_Luong.Size = new System.Drawing.Size(23, 20);
            this.txtDM_Luong.TabIndex = 4;
            this.txtDM_Luong.Text = "T";
            this.txtDM_Luong.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtDM_Luong.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDM_Luong.Value = "T";
            // 
            // lblDM_Luong
            // 
            this.lblDM_Luong.AutoSize = true;
            this.lblDM_Luong.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDM_Luong.Location = new System.Drawing.Point(12, 115);
            this.lblDM_Luong.Name = "lblDM_Luong";
            this.lblDM_Luong.Size = new System.Drawing.Size(58, 14);
            this.lblDM_Luong.TabIndex = 91;
            this.lblDM_Luong.Text = "Loại số dư";
            // 
            // lblMa_Vt
            // 
            this.lblMa_Vt.AutoSize = true;
            this.lblMa_Vt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Vt.Location = new System.Drawing.Point(12, 136);
            this.lblMa_Vt.Name = "lblMa_Vt";
            this.lblMa_Vt.Size = new System.Drawing.Size(37, 14);
            this.lblMa_Vt.TabIndex = 78;
            this.lblMa_Vt.Text = "Vật tư";
            // 
            // txtTen_Vt
            // 
            this.txtTen_Vt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Vt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Vt.CheckTextSearched = false;
            this.txtTen_Vt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Vt.Enabled = false;
            this.txtTen_Vt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Vt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Vt.Location = new System.Drawing.Point(210, 136);
            this.txtTen_Vt.Name = "txtTen_Vt";
            this.txtTen_Vt.OldValue = null;
            this.txtTen_Vt.Size = new System.Drawing.Size(286, 13);
            this.txtTen_Vt.TabIndex = 80;
            this.txtTen_Vt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Vt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Vt.Value = ((object)(resources.GetObject("txtTen_Vt.Value")));
            // 
            // txtMa_Vt
            // 
            this.txtMa_Vt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Vt.CheckTextSearched = false;
            this.txtMa_Vt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Vt.EmptyIsValid = true;
            this.txtMa_Vt.FieldDisplay = "Ten_Vt";
            this.txtMa_Vt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Vt.FoundIsValid = true;
            this.txtMa_Vt.Location = new System.Drawing.Point(93, 133);
            this.txtMa_Vt.MaxLength = 32;
            this.txtMa_Vt.Name = "txtMa_Vt";
            this.txtMa_Vt.OldValue = null;
            this.txtMa_Vt.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Vt.TabIndex = 5;
            this.txtMa_Vt.TableName = "DMVT";
            this.txtMa_Vt.TextDisplay = this.txtTen_Vt;
            this.txtMa_Vt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Vt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Vt.Value = ((object)(resources.GetObject("txtMa_Vt.Value")));
            // 
            // txtGia
            // 
            this.txtGia.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtGia.Location = new System.Drawing.Point(93, 175);
            this.txtGia.Name = "txtGia";
            this.txtGia.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtGia.OldValue = null;
            this.txtGia.Size = new System.Drawing.Size(162, 20);
            this.txtGia.TabIndex = 7;
            this.txtGia.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtGia.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.LocalPrice;
            this.txtGia.Value = ((object)(resources.GetObject("txtGia.Value")));
            this.txtGia.Validated += new System.EventHandler(this.txtGia_Validated);
            // 
            // lblGia
            // 
            this.lblGia.AutoSize = true;
            this.lblGia.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblGia.Location = new System.Drawing.Point(12, 178);
            this.lblGia.Name = "lblGia";
            this.lblGia.Size = new System.Drawing.Size(45, 14);
            this.lblGia.TabIndex = 86;
            this.lblGia.Text = "Đơn giá";
            // 
            // txtTien_Nt
            // 
            this.txtTien_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTien_Nt.Location = new System.Drawing.Point(366, 196);
            this.txtTien_Nt.Name = "txtTien_Nt";
            this.txtTien_Nt.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTien_Nt.OldValue = null;
            this.txtTien_Nt.Size = new System.Drawing.Size(162, 20);
            this.txtTien_Nt.TabIndex = 10;
            this.txtTien_Nt.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTien_Nt.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.txtTien_Nt.Value = ((object)(resources.GetObject("txtTien_Nt.Value")));
            this.txtTien_Nt.Validated += new System.EventHandler(this.txtTien_Nt_Validated);
            // 
            // txtGia_Nt
            // 
            this.txtGia_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtGia_Nt.Location = new System.Drawing.Point(366, 175);
            this.txtGia_Nt.Name = "txtGia_Nt";
            this.txtGia_Nt.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtGia_Nt.OldValue = null;
            this.txtGia_Nt.Size = new System.Drawing.Size(162, 20);
            this.txtGia_Nt.TabIndex = 9;
            this.txtGia_Nt.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtGia_Nt.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.ForeignPrice;
            this.txtGia_Nt.Value = ((object)(resources.GetObject("txtGia_Nt.Value")));
            this.txtGia_Nt.Validated += new System.EventHandler(this.txtGia_Nt_Validated);
            // 
            // lblTien_Nt
            // 
            this.lblTien_Nt.AutoSize = true;
            this.lblTien_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTien_Nt.Location = new System.Drawing.Point(264, 199);
            this.lblTien_Nt.Name = "lblTien_Nt";
            this.lblTien_Nt.Size = new System.Drawing.Size(86, 14);
            this.lblTien_Nt.TabIndex = 86;
            this.lblTien_Nt.Text = "Giá trị nguyên tệ";
            // 
            // lblGia_Nt
            // 
            this.lblGia_Nt.AutoSize = true;
            this.lblGia_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblGia_Nt.Location = new System.Drawing.Point(264, 178);
            this.lblGia_Nt.Name = "lblGia_Nt";
            this.lblGia_Nt.Size = new System.Drawing.Size(96, 14);
            this.lblGia_Nt.TabIndex = 86;
            this.lblGia_Nt.Text = "Đơn giá nguyên tệ";
            // 
            // FormCDSEditor
            // 
            this.AddTitleText = "Thêm số dư đầu kỳ công trình";
            this.ClientSize = new System.Drawing.Size(540, 228);
            this.Controls.Add(this.lblDM_Luong0);
            this.Controls.Add(this.txtDM_Luong);
            this.Controls.Add(this.lblDM_Luong);
            this.Controls.Add(this.txtMa_Vt);
            this.Controls.Add(this.txtMa_Dt);
            this.Controls.Add(this.txtTk_Du);
            this.Controls.Add(this.txtTk);
            this.Controls.Add(this.txtMa_Sp);
            this.Controls.Add(this.lblSo_Luong);
            this.Controls.Add(this.txtTen_Vt);
            this.Controls.Add(this.lblGia_Nt);
            this.Controls.Add(this.lblGia);
            this.Controls.Add(this.lblTien_Nt);
            this.Controls.Add(this.lblTien);
            this.Controls.Add(this.txtTen_Dt);
            this.Controls.Add(this.txtSo_Luong);
            this.Controls.Add(this.txtTen_Tk_Du);
            this.Controls.Add(this.lblMa_Vt);
            this.Controls.Add(this.txtGia_Nt);
            this.Controls.Add(this.txtTien_Nt);
            this.Controls.Add(this.txtGia);
            this.Controls.Add(this.txtTien);
            this.Controls.Add(this.lblMa_Dt);
            this.Controls.Add(this.txtTen_Tk);
            this.Controls.Add(this.lblTk_Du);
            this.Controls.Add(this.txtTen_Sp);
            this.Controls.Add(this.lblTk);
            this.Controls.Add(this.lblMa_Sp);
            this.EditTitleText = "Sửa số dư đầu kỳ công trình";
            this.Name = "FormCDSEditor";
            this.Text = "Thêm số dư đầu kỳ công trình";
            this.Controls.SetChildIndex(this.lblMa_Sp, 0);
            this.Controls.SetChildIndex(this.lblTk, 0);
            this.Controls.SetChildIndex(this.txtTen_Sp, 0);
            this.Controls.SetChildIndex(this.lblTk_Du, 0);
            this.Controls.SetChildIndex(this.txtTen_Tk, 0);
            this.Controls.SetChildIndex(this.lblMa_Dt, 0);
            this.Controls.SetChildIndex(this.txtTien, 0);
            this.Controls.SetChildIndex(this.txtGia, 0);
            this.Controls.SetChildIndex(this.txtTien_Nt, 0);
            this.Controls.SetChildIndex(this.txtGia_Nt, 0);
            this.Controls.SetChildIndex(this.lblMa_Vt, 0);
            this.Controls.SetChildIndex(this.txtTen_Tk_Du, 0);
            this.Controls.SetChildIndex(this.txtSo_Luong, 0);
            this.Controls.SetChildIndex(this.txtTen_Dt, 0);
            this.Controls.SetChildIndex(this.lblTien, 0);
            this.Controls.SetChildIndex(this.lblTien_Nt, 0);
            this.Controls.SetChildIndex(this.lblGia, 0);
            this.Controls.SetChildIndex(this.lblGia_Nt, 0);
            this.Controls.SetChildIndex(this.txtTen_Vt, 0);
            this.Controls.SetChildIndex(this.lblSo_Luong, 0);
            this.Controls.SetChildIndex(this.txtMa_Sp, 0);
            this.Controls.SetChildIndex(this.txtTk, 0);
            this.Controls.SetChildIndex(this.txtTk_Du, 0);
            this.Controls.SetChildIndex(this.txtMa_Dt, 0);
            this.Controls.SetChildIndex(this.txtMa_Vt, 0);
            this.Controls.SetChildIndex(this.lblDM_Luong, 0);
            this.Controls.SetChildIndex(this.txtDM_Luong, 0);
            this.Controls.SetChildIndex(this.lblDM_Luong0, 0);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnReset()
        {
            if (base.NewChecked)
            {
                this.txtMa_Vt.Value = "";
                this.txtTen_Vt.Value = "";
                this.txtSo_Luong.Value = 0;
                this.txtGia.Value = 0;
                this.txtTien.Value = 0;
                this.txtGia_Nt.Value = 0;
                this.txtTien_Nt.Value = 0;
            }
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (AppInstance.EndingDateOfSubEnterprice >= AppInstance.OpeningDateOfSubEnterprice)
            {
                MessageBox.Show("Đã khóa dữ liệu!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (this.txtSo_Luong.NumericValue == 0M)
            {
                MessageBox.Show("Chưa nhập số lượng sản phẩm dở dang!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
                localCurrentRow["Ma_Dvcs"] = AppInstance.Subsidiary;
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Sp"] = this.txtMa_Sp.Value;
            localCurrentRow["Ten_Sp"] = this.txtTen_Sp.Value;
            localCurrentRow["Tk"] = this.txtTk.Value;
            localCurrentRow["Tk_Du"] = this.txtTk_Du.Value;
            localCurrentRow["Ma_Dt"] = this.txtMa_Dt.Value;
            localCurrentRow["DM_Luong"] = this.txtDM_Luong.Value;
            localCurrentRow["Ma_Vt"] = this.txtMa_Vt.Value;
            localCurrentRow["So_Luong"] = this.txtSo_Luong.Value;
            localCurrentRow["Tien"] = this.txtTien.Value;
            localCurrentRow["Tien_Nt"] = this.txtTien_Nt.Value;
            CDSDataAccess access = new CDSDataAccess();
            if (access.Save(base.NewChecked, localCurrentRow) == -1)
            {
                MessageBox.Show("Sản phẩm đã được ghi nhận!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            base.SavedMasterOrder = localCurrentRow["Stt"];
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Sp.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Sp.Value = base.LocalCurrentRow["Ma_Sp"];
            this.txtTen_Sp.Value = base.LocalCurrentRow["Ten_Sp"];
            this.txtTk.Value = base.LocalCurrentRow["Tk"];
            this.txtTen_Tk.Value = this.txtTk.GetFieldData("Ten_Tk");
            this.txtTk_Du.Value = base.LocalCurrentRow["Tk_Du"];
            this.txtTen_Tk_Du.Value = this.txtTk_Du.GetFieldData("Ten_Tk");
            this.txtMa_Dt.Value = base.LocalCurrentRow["Ma_Dt"];
            this.txtTen_Dt.Value = this.txtMa_Dt.GetFieldData("Ten_Dt");
            this.txtDM_Luong.Value = base.LocalCurrentRow["DM_Luong"];
            this.txtMa_Vt.Value = base.LocalCurrentRow["Ma_Vt"];
            this.txtTen_Vt.Value = this.txtMa_Vt.GetFieldData("Ten_Vt");
            this.txtSo_Luong.Value = base.LocalCurrentRow["So_Luong"];
            this.txtTien.Value = base.LocalCurrentRow["Tien"];
            this.txtTien_Nt.Value = base.LocalCurrentRow["Tien_Nt"];
            this.Calculate(3);
            this.Calculate(5);
        }

        private void txtGia_Nt_Validated(object sender, EventArgs e)
        {
            if (this.txtGia_Nt.ValueChanged)
            {
                this.Calculate(4);
            }
        }

        private void txtGia_Validated(object sender, EventArgs e)
        {
            if (this.txtGia.ValueChanged)
            {
                this.Calculate(2);
            }
        }

        private void txtSo_Luong_Validated(object sender, EventArgs e)
        {
            if (this.txtSo_Luong.ValueChanged)
            {
                this.Calculate(1);
            }
        }

        private void txtTien_Nt_Validated(object sender, EventArgs e)
        {
            if (this.txtTien_Nt.ValueChanged)
            {
                this.Calculate(5);
            }
        }

        private void txtTien_Validated(object sender, EventArgs e)
        {
            if (this.txtTien.ValueChanged)
            {
                this.Calculate(3);
            }
        }
    }
}

